# -*- coding: utf-8 -*-

from multiprocessing import Process
import time

def task(name):
    print('%s is running' % name)
    time.sleep(3)
    print('%s is done' % name)

if __name__ == '__main__':
    p1 = Process(target=task, kwargs={'name': '小明'})
    p2 = Process(target=task, kwargs={'name': '小红'})
    # 主进程只是向操作系统发送了一个开启子进程的信号
    p1.start()
    p2.start()
    # join让主进程等待子进程运行完
    p1.join()
    p2.join()
    print('主进程')
    '''
    运行结果：根据计算机实际运行情况，结果可能不一致
    小明 is running
    小红 is running
    小明 is done
    小红 is done
    主进程
    '''